All Questions
17 questions
3votes
1answer
3kviews
Recursive solution of ordered Coin Combinations II (CSES)
Question Link Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using ...
1vote
2answers
343views
Leetcode 377. Combination Sum IV Javascript Memoization attempt
Problem Statement ...
3votes
0answers
135views
C++ - Longest Common Subsequence
Link to the Problem Here is my code to compute the length of the longest common subsequence of two integer arrays arr[] and brr[]...
1vote
2answers
247views
Recursive brute-force approach to maximum points you can obtain from cards
I came across this question on Leetcode. The question description is as follows: There are several cards arranged in a row, and each card has an associated number of points. The points are given in ...
2votes
1answer
167views
How do I optimize memoization in order to find longest palindromic substring?
I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string. I have seen other questions on this problem that successfully solve ...
1vote
1answer
636views
CodeChef Matches challenge
I am solving some problems from CodeChef but I am stuck on the Matches problem: Ari and Rich are playing a pretty confusing game. Here are the rules of the game: The game is played with ...
2votes
1answer
795views
Given a string and a word dict, find all possible sentences
I have been trying to figure out how to meet space and time complexity requirements for the following leet code question. I have come up with two versions, one that meets the time requirements and ...
-2votes
1answer
1kviews
Dynamic Programming solution for one pile nim game
I have solved the following problem using dynamic programming: Little Deepu and his Girlfriend 1. To paraphrase, We have two players Little Deepu and Kate and M items in the bag B, also we have a ...
3votes
3answers
344views
SPOJ Emoticon challenge
I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input ...
3votes
1answer
929views
SPOJ - Alphacode, using dynamic programming
I am currently trying out a programming problem, SPOJ Alphacode, that involves dynamic programming. In an encoding system where A=1, B=2, …, Z=26, a message 25114 ...
5votes
1answer
1kviews
Hackerrank "Bricks Game"
Problem URL This is the solution I came up with the minimax problem stated above. I did a top-down recursive approach with memoization, and I think this should be \$O(n)\$, since we are filling out a ...
1vote
3answers
1kviews
Code for calculating best possible combination in an array
The problem here , requires me to find the best possible combination of values in an array which is nearest to 0 and are adjacent to each other , here is an little excerpt from it, The government of ...
5votes
2answers
704views
Number of ways to make change for an amount
Task Write a program that, given the amount to make change for and a list of coins prints out how many different ways you can make change from the coins to STDOUT. My approach The number to make ...
6votes
1answer
121views
Optimal way to annihilate a list by removing items from the ends
I'm stuck with a contest problem. Description: What is the minimum number of moves to annihilate an int array where the possible moves are: Remove both the first and last elements if they are equal ...
4votes
1answer
946views
Optimizing a dynamic programming solution for "Oil Well"
I'm trying to solve the Oil Well problem on Hackerrank using dynamic programming and it works. However, it times out for some of the test cases. I wanted to know how this program can be improved so ...